package org.kanglg.demo.web;

import org.kanglg.demo.entity.Dept;
import org.kanglg.demo.entity.User;
import org.kanglg.demo.service.DeptBS;
import org.kanglg.demo.service.UserBS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/home")
public class HomeController {
    @Autowired
    UserBS user;
    @Autowired
    DeptBS dept;
    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView index() {
        User userEntity = user.getUser("1");
        ModelMap mm = new ModelMap();
        mm.put("userEntity", userEntity);
        Dept d = dept.getEntity("1");
        Dept d2 = new Dept();
        d2.setDeptName("shanxi");
        d2.setId("2");
        dept.addNode(null, d2);
        return new ModelAndView("/home", mm);
    }
}
